package com.cavy.platform.server.dto;

import com.cavy.platform.server.validator.*;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.GroupSequence;
import javax.validation.constraints.NotNull;

/**
 * @author 唐旭
 * @Date 2018/7/25
 */
@Data
@Accessors(chain = true)
@GroupSequence({FormatValidatorGroup.class, LastValidatorGroup.class, PipelineRunDto.class})
@PipelineExist(message = "流水线不存在", groups = LastValidatorGroup.class)
@ProjectExist(message = "项目不存在", groups = LastValidatorGroup.class)
public class PipelineRunDto implements ProjectExistData, PipelineExistData {
    @NotNull(message = "流水线名称不能为空", groups = FormatValidatorGroup.class)
    private String name;
    @NotNull(message = "项目名称不能为空", groups = FormatValidatorGroup.class)
    private String projectName;
    @NotNull(message = "工作空间不能为空", groups = FormatValidatorGroup.class)
    @WorkspaceExist(groups = LastValidatorGroup.class)
    private String workspace;

    @Override
    public String getProjectPropertyName() {
        return "projectName";
    }

    @Override
    public String getPipelineName() {
        return name;
    }

    @Override
    public String getPipelineFieldName() {
        return "name";
    }
}
